﻿/*
 * Created by SharpDevelop.
 * User: IEscarro
 * Date: 8/28/2009
 * Time: 10:12 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */

using System;
using System.Collections.Generic;

namespace Miming.Model
{
	/// <summary>
	/// Description of Module.
	/// </summary>
	public class Module
	{
		int id;
		IList<Privilege> privileges = new List<Privilege>();
		string code;
		
		public virtual string Code {
			get { return code; }
			set { code = value; }
		}
		
		public virtual IList<Privilege> Privileges {
			get { return privileges; }
			set { privileges = value; }
		}
		
		public virtual int Id {
			get { return id; }
			set { id = value; }
		}
		string name;
		
		public virtual string Name {
			get { return name; }
			set { name = value; }
		}
		
		public Module()
		{
		}
		
		public virtual void AddPrivilege(Privilege p)
		{
			p.Module = this;
			privileges.Add(p);
			OnPrivilegeAdded(null);
		}
		
		protected virtual void OnPrivilegeAdded(EventArgs e)
		{
			if (PrivilegeAdded != null) {
				PrivilegeAdded(this, e);
			}
		}
		
		public virtual event EventHandler PrivilegeAdded;
	}
	
	public class UserModule 
	{
		int id;
		
		public virtual int Id {
			get { return id; }
			set { id = value; }
		}
		Module module;
		
		public virtual Module Module {
			get { return module; }
			set { module = value; }
		}
		User user;
		
		public virtual User User {
			get { return user; }
			set { user = value; }
		}
		
		public UserModule()
		{
		}
	}
}
